<?php

//

require_once '/../Modele/Repere.php';
require_once '/../Controleur/Carte_controleur.php';


if (!isset($_SESSION)) {
    session_start();
}
$controleur = new Carte_controleur();

if ($_POST['action'] == 'get') {
    $listeRepere = $controleur->getListeRepere($_POST['idPerso']);
    echo json_encode($listeRepere);
} else if ($_POST['action'] == 'add') {

    $lat = $_POST['lat'];
    $long = $_POST['long'];
    $type = $_POST['type'];
    $perso = $_POST['perso'];
    $user = $_SESSION['idUser'];
    $episode = $controleur->getIdEpisode($_POST['saison'], $_POST['episode']);
    $info = $_POST['info'];

    $controleur->soumettreRepere($lat, $long, $type, $perso, $user, $episode, $info);
} else if ($_POST['action'] == 'nbEpisode') {
    echo $controleur->getNbEpisodeBySaison($_POST['saison']);
}